﻿@model LeadMaster.ViewModels.ViewModelLeadBuilder

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <div class="spacer"></div>
    <fieldset>
        <legend style="font-family: Arial, Helvetica, sans-serif; font-variant: small-caps; color: #000000; font-size: large;">Lead Builder For @Model.LeadTemplate.Title</legend>

        @Html.HiddenFor(model => model.LeadTemplate .LeadTemplateID)
        <table style="width: 850px;">
        <tr>
        <thead>
        <th><label style="font-family: Trebuchet MS; font-variant: small-caps; color: #000000; font-size: medium;">Sector</label></th>
        <th><label  style="font-family: Trebuchet MS; font-variant: small-caps; color: #000000; font-size: medium;">Title</label></th>
        <th><label  style="font-family: Trebuchet MS; font-variant: small-caps; color: #000000; font-size: medium;">Linked Groupsets ?</label></th>
        </thead>
        </tr>
        <tr>
        <td>@Html.DropDownList("LeadTemplate_SectorID", null, new { style = "width:300px;font-family: Arial, Helvetica, sans-serif; font-size: large;background-color: #4c4c4c; color: #ffffff" })
            @Html.ValidationMessageFor(model => model.LeadTemplate.SectorID)</td>
        <td>@Html.TextBoxFor(model => model.LeadTemplate.Title, new { style = "width:300px;font-family: Arial, Helvetica, sans-serif; font-size: large; font-weight:normal;background-color: #4c4c4c; color: #ffffff" })
            @Html.ValidationMessageFor(model => model.LeadTemplate.Title)</td>
        <td>
        <input type="checkbox" id="LinkedGroupSets" name="LeadTemplate.LinkedGroupSets" 
        @if(Model.LeadTemplate.LinkedGroupSets!=null && Model.LeadTemplate.LinkedGroupSets==true)
        {
         @:checked   
        }
        value="true"
        />
        </td>

        </tr>
        </table>
        <hr id="hrStartLeadStat"/>
        <div>
        <label style="font-family: Arial, Helvetica, sans-serif; font-variant: small-caps; color: #000000; font-size: medium;">Statutory Section</label>
        </div>
        <input type="button" value="+" id="btnAddLeadStat" />
        <div class="spacer"></div>
        <div id="AddLeadStat">
        </div>
        <div id="EditLeadStat">
        </div>
        <div id="ShowLeadStat">
        </div>
        <hr id="hrEndLeadStat" />
        <hr />
        <div>
        <label style="font-family: Arial, Helvetica, sans-serif; font-variant: small-caps; color: #000000; font-size: medium;">Groups Section</label>
        </div>
        <input type="button" value="+" id="btnAddLeadGroup" />
        <div class="spacer"></div>
        <div id="AddLeadGroup">
        </div>
        <div id="ShowLeadGroups">
        </div>
        <div id="EditLeadGroup">
        </div>
        <hr/>
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}
<div class="spacer"></div>
<div>
    @Html.ActionLink("Preview", "PreviewQuestionnaire", new { templateTitle = Model.LeadTemplate.Title }, new { target="_blank"})
</div>
<div class="spacer"></div>
<div>
    @Html.ActionLink("Back to List", "Index")
</div>


@section Scripts {

    <script type="text/javascript">
        $(document).ready(function () {

            $("#LeadTemplate_SectorID").attr('name', 'LeadTemplate.SectorID')
            $('#ShowLeadStat').load('@(Url.Action("ShowLeadStat", "LeadBuilder"))/?id=' + @(Model.LeadTemplate.LeadTemplateID));
            $('#ShowLeadGroups').load('@(Url.Action("ShowLeadGroups", "LeadBuilder"))/?id=' + @(Model.LeadTemplate.LeadTemplateID));

            $("#AddLeadStat").dialog(
            {
                autoOpen: false,
                width: 900,
                open: function () { $(".ui-dialog").css("box-shadow", "#000 5px 5px 5px"); },
                position: ['middle', 20],
                modal: true,
                dialogClass: 'notitle',
                buttons: {
                    save: function() {
                        $(this).dialog("close");
                        $("#formAddLeadStat").submit();
                    },
                    cancel: function () {
                        $(this).dialog("close");
                    }
                }
            });

            $("#EditLeadStat").dialog(
            {
                autoOpen: false,
                width: 900,
                open: function () { $(".ui-dialog").css("box-shadow", "#000 5px 5px 5px"); },
                position: ['middle', 20],
                modal: true,
                dialogClass: 'notitle',
                buttons: {
                    save: function() {
                        $(this).dialog("close");
                        $("#formEditLeadStat").submit();
                    },
                    cancel: function () {
                        $(this).dialog("close");
                    }
                }
            });

            $("#EditLeadGroup").dialog(
            {
                autoOpen: false,
                width: 900,
                open: function () { $(".ui-dialog").css("box-shadow", "#000 5px 5px 5px"); },
                position: ['middle', 20],
                modal: true,
                dialogClass: 'notitle',
                buttons: {
                    save: function() {
                        $(this).dialog("close");
                        $("#formEditLeadGroup").submit();
                    },
                    cancel: function () {
                        $(this).dialog("close");
                    }
                }
            });

            $("#btnAddLeadStat").click(function () {
                $("#AddLeadStat").dialog("open");
                $('#AddLeadStat').html('<div style="text-align: center;"><div><img src="@Url.Content("~/Images/ajaxspinner_large.gif")" alt="Loading..." style="margin: 20px;" /></div><div>Loading...</div></div>');
                var contactURL='@(Url.Action("AddLeadStat", "LeadBuilder"))/?id=' + @(Model.LeadTemplate.LeadTemplateID);
                $('#AddLeadStat').load(contactURL);
            });

            $("#AddLeadGroup").dialog(
            {
                autoOpen: false,
                width: 900,
                open: function () { $(".ui-dialog").css("box-shadow", "#000 5px 5px 5px"); },
                position: ['middle', 20],
                modal: true,
                dialogClass: 'notitle',
                buttons: {
                    save: function() {
                        $(this).dialog("close");
                        $("#formAddLeadGroup").submit();
                    },
                    cancel: function () {
                        $(this).dialog("close");
                    }
                }
            });

            $("#btnAddLeadGroup").click(function () {
                $("#AddLeadGroup").dialog("open");
                $('#AddLeadGroup').html('<div style="text-align: center;"><div><img src="@Url.Content("~/Images/ajaxspinner_large.gif")" alt="Loading..." style="margin: 20px;" /></div><div>Loading...</div></div>');
                var contactURL='@(Url.Action("AddLeadGroup", "LeadBuilder"))/?id=' + @(Model.LeadTemplate.LeadTemplateID);
                $('#AddLeadGroup').load(contactURL);
            });


        });
    </script>
}
